package script

import (
	"game/core"

	"github.com/hajimehoshi/ebiten/v2"
	"github.com/solarlune/resolv"
)

type Boom struct {
	core.Sprite
	Animation          *core.Animation
	ProjectileMovement core.ProjectileMovement
}

func NewBoom(position resolv.Vector) *Boom {
	b := &Boom{
		Sprite: core.Sprite{
			Position: &position,
			Scale:    &resolv.Vector{X: 1, Y: 1},
			Image:    BoomImg[0],
		},
		ProjectileMovement: core.ProjectileMovement{Lifetime: 2},
	}
	//
	b.Animation = core.NewAnimation(&core.AnimationOption{Frames: []*core.Frame{
		{Image: BoomImg[0]},
		{Image: BoomImg[1]},
		{Image: BoomImg[2]},
		{Image: BoomImg[3]},
		{Image: BoomImg[4]},
		{Image: BoomImg[5]},
	}, Delay: 3, IsLooping: false})
	b.SetPosition(position)
	return b
}
func (b *Boom) Update(dt float64) error {
	b.Animation.Update(dt)
	return nil
}

func (b *Boom) Draw(screen *ebiten.Image) {
	b.Animation.Draw(screen, b.Scale, b.Position)
}
